package com.lvmama.controller.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lvmama.common.result.Result;
import com.lvmama.pojo.base.Page;
import com.lvmama.pojo.dto.rhino.system.MenuDTO;
import com.lvmama.pojo.dto.rhino.system.MenuQueryDTO;
import com.lvmama.pojo.entity.rhino.system.Menu;
import com.lvmama.pojo.entity.rhino.system.User;
import com.lvmama.service.system.MenuService;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    MenuService menuService;

    @PostMapping("/getAllMenuListByUser")
    public Result<List<Menu>> getAllMenuListByUser(@RequestBody User user){
        return menuService.getAllMenuListByUser(user);
    }

    @PostMapping("/getMenuList")
    public Result<Page<Menu>> getMenuList(@RequestBody MenuQueryDTO query){
        return menuService.getMenuList(query);
    }

    @GetMapping("/getMenuById")
    public Result<Menu> getMenuById(@RequestParam("id") String id){
        return menuService.getMenuById(id);
    }

    @GetMapping("/delete")
    public Result<Boolean> deleteMenuById(@RequestParam("id") String id){
        return menuService.deleteMenuById(id);
    }

    @GetMapping("/icons")
    public Result<List<String>> getMenuIcons(){
        return menuService.getMenuIcons();
    }

    @PostMapping("/update")
    public Result<Boolean> updateMenu(@RequestBody MenuDTO menuDTO){
        return menuService.updateMenu(menuDTO);
    }

    @PostMapping("/save")
    public Result<Boolean> saveMenu(@RequestBody MenuDTO menuDTO){
        return menuService.saveMenu(menuDTO);
    }
}
